import type { IQuery, IResponse, TableResponse } from '@/api/config/types';
import axios from 'axios';

export interface Station {
  stationId: string;
  stationNum: string;
  stationName: string;
  stationIp: string;
  mac: string;
  status: string;
  deptId: string;
  rangeTag: number;
  sendTimes: number;
  createTime: string;
  retainSend: number;
}
/* 新基站 */
export interface NewStation {
  action: string;
  stationNum: string;
  stationIp: string;
  mac: string;
  time: string;
}

const prefix = '/station/station';

// 查询基站管理列表
export const listStation = (query?: IQuery) => {
  return axios.get<TableResponse<Station>>(`${prefix}/list`, { params: query });
};

// 查询基站管理列表
export const queryStation = () => {
  return axios.get<IResponse<Station[]>>(`${prefix}/query`);
};

// 删除基站管理
export const delStation = (stationId: Array<string>) => {
  return axios.delete(`${prefix}/${stationId.join(',')}`);
};

// 新增基站管理
export const addStation = (data: Station) => {
  return axios.post(`${prefix}`, data);
};

// 获取基站新闻
export const getStationNews = () => {
  return axios.get<IResponse<Array<NewStation>>>(`${prefix}/news`);
};

// 更新基站信息
export const updateStation = (data: Station) => {
  return axios.put(`${prefix}`, data);
};

// 更新硬件
export const upgradeStation = (data: any) => {
  return axios.post(`${prefix}/upgrade`, data);
};

// 更新硬件
export const getStationById = (id: string | number) => {
  return axios.get<IResponse<Station>>(`${prefix}/${id}`);
};

// 查询基站下的所有列表
export const manageList = (query: IQuery) => {
  return axios.get('/v2/station/manage/list', { params: query });
};
